<template>
    <div>
        <br /><br />
        <el-table ref="multipleTable" v-loading="listLoading" :data="list" size="small" style="width: 90%;"
            @sort-change="sortChange" @selection-change="handleSelectionChange" @row-click="handleRowClick">
            <el-table-column type="selection" width="44px"></el-table-column>
            <el-table-column label="发货申请主题" prop="sTitle" align="center" />
            <el-table-column label="发货申请编号" prop="sNum" align="center" />
            <el-table-column label="申请人" prop="aPeo" align="center" />
            <el-table-column label="应发日期" prop="sTime" align="center" />
            <el-table-column label="发货状态" prop="createOrUpdateSendDto[0].sIsta" align="center">
                <template slot-scope="scope">
                    <template v-if="scope.row.sIsta">
                        <el-tag>待发货</el-tag>
                    </template>
                    <template v-else>
                        <el-tag type="success">已发货</el-tag>
                    </template>
                </template>
            </el-table-column>


            <el-table-column label="发货人" prop="rPeo" align="center" />
            <el-table-column label="客户/供应商" prop="sCom" align="center" />
            <el-table-column label="关联合同/采购退货" prop="price" align="center" />

            <el-table-column label="关联项目" prop="price" align="center" />
            <el-table-column label="操作" align="center">
                <template slot-scope="{row}">
                    <el-button type="primary" size="mini" @click="handleUpdate(row)" icon="el-icon-edit" />
                    <el-button type="danger" size="mini" @click="handleDelete(row)" icon="el-icon-delete" />
                </template>
            </el-table-column>
        </el-table>
        <pagination v-show="totalCount > 0" :total="totalCount" :page.sync="page" :limit.sync="listQuery.MaxResultCount"
            @pagination="getList" />
    </div>
</template>
<script>
import Pagination from "@/components/Pagination";
import permission from "@/directive/permission/index.js";
import { cloneDeep } from "lodash";

export default {
    name: 'Book',
    components: {
        Pagination
    },
    directives: {
        permission
    },
    props: [],
    data() {
        return {

            list: [],
            totalCount: 0,
            listLoading: true,
            formLoading: false,
            listQuery: {
                Filter: '',
                Sorting: '',
                SkipCount: 0,
                MaxResultCount: 10
            },
            page: 1,
            dialogFormVisible: false,
            multipleSelection: [],
            formTitle: '',
            isEdit: false,
        }
    },
    computed: {},
    watch: {},
    created() {
        this.getList()
    },
    mounted() { },
    methods: {
        getListStatus(items, ids) {
            this.$axios.posts('api/business/workflow/node-status', ids).then(response => {
                items.forEach(element => { response.items.filter((i) => { if (i.entityId === element.id) { element.status = i.status; element.nodeId = i.nodeId; element.nodeStatus = i.nodeName } }) })
                this.list = items
                this.listLoading = false;
            });
        },
        getList() {
            this.listLoading = true;
            this.listQuery.SkipCount = (this.page - 1) * this.listQuery.MaxResultCount;
            this.$axios.gets('/api/business/send/good', this.listQuery).then(response => {
                this.totalCount = response.totalCount;
                this.getListStatus(response.items, response.items.map(_ => _.id))
            });
        },

        handleFilter() {
            this.page = 1;
            this.getList();
        },



    }
}
</script>
<style></style>
